package com.yry.timertask.chapter41;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimerTask;

public class MyTimerTaskQx extends TimerTask{
	private  String name;
	private long costTime;

	public MyTimerTaskQx(String name, long costTime) {
		this.name = name;
		this.costTime = costTime;
	}

	@Override
	public void run() {
		Calendar cale = Calendar.getInstance();
		SimpleDateFormat sf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println(name +"'s Current exec time is:"+sf.format(cale.getTime()));


		try {
			Thread.sleep(costTime);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		cale = Calendar.getInstance();
		System.out.println(name + "'s finish time is:"+sf.format(cale.getTime()));
//		throw new RuntimeException();

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getCostTime() {
		return costTime;
	}

	public void setCostTime(long costTime) {
		this.costTime = costTime;
	}
}
